<!--
 * @name: 
 * @Author: JiaYing
 * @LastEditors: JiaYing
 * @Date: 2022-08-29 13:45:48
 * @LastEditTime: 2022-08-29 15:00:25
 * @Description: 
-->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>变量转换与运算</title>
  </head>
  <body></body>
</html>

<script>
  console.log(+1, +"1", +0, +new Date(), +true, +false);
  console.log(-1, -"1", -0, -new Date(), -true, -false);
  console.log(1 - +1, 1 - -1);
  var a = 1;
  console.log(a++, (a = 1), ++a);
  a = 1;
  console.log(1 - a++, a, 1 - ++a);
  a = 2;
  console.log(1 - a++ + 1, a, 1 - ++a + 1);
  a = 2;
  console.log(a++ + a, (a = 2), ++a + a);

  function Num() {
    this.value = 1;
  }
  Num.prototype.valueOf = function () {
    return this.value;
  };
  Num.prototype.toString = function (v) {
    return "toString:" + this.value;
  };
  // valueOf > toString
  const n = new Num();
  console.log(+n, n + "a", String(n));
</script>
